Range Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Returns a collection that can be used for enumerating some of the keys and values in the collection. Only keys that are greater than from and less than to are included. The keys are enumerated in sorted order. Keys equal to the end points of the range can be included or excluded depending on the fromInclusive and toInclusive parameters.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public OrderedMultiDictionary<TKey, TValue>.OrderedMultiDictionary<(Of <TKey, TValue>)>..::View Range(
	TKey from,
	bool fromInclusive,
	TKey to,
	bool toInclusive
)
Visual Basic (Declaration)
Public Function Range ( _
	from As TKey, _
	fromInclusive As Boolean, _
	to As TKey, _
	toInclusive As Boolean _
) As OrderedMultiDictionary<(Of <TKey, TValue>)>..::View
Visual C++
public:
OrderedMultiDictionary<(Of <TKey, TValue>)>..::View^ Range (
	TKey from, 
	bool fromInclusive, 
	TKey to, 
	bool toInclusive
)

Parameters

from
TKey
The lower bound of the range.
fromInclusive
Boolean
If true, the lower bound is inclusive--keys equal to the lower bound will be included in the range. If false, the lower bound is exclusive--keys equal to the lower bound will not be included in the range.
to
TKey
The upper bound of the range.
toInclusive
Boolean
If true, the upper bound is inclusive--keys equal to the upper bound will be included in the range. If false, the upper bound is exclusive--keys equal to the upper bound will not be included in the range.

Return Value

An OrderedMultiDictionary.View of key-value pairs in the given range.

Remarks

If from is greater than or equal to to, the returned collection is empty.

The sorted order of the keys is determined by the comparison instance or delegate used to create the dictionary.

Typically, this property is used in conjunction with a foreach statement. For example:

 Copy imageCopy Code
             foreach(KeyValuePair<TKey, TValue> pair in dictionary.Range(from, true, to, false)) {
                // process pair
             }
            

Calling Range does not copy the data in the dictionary, and the operation takes constant time.

See Also